import {lib,game,ui,get,ai,_status} from '../../../noname.js'
export const card = {
    connect:true,
    //在这里编写卡牌信息。
    card:{
        'djcjiguchuanhua':{//击鼓传花 出牌阶段，你可以与一名体力值大于你的其他角色拼点。输的角色须选择一项:1.视为使用一张【击鼓传花】；2.受到X点伤害（X为本回合所有角色使用【击鼓传花】的次数）。
            audio:true,
            image:'ext:点绛唇/card/image/djcjiguchuanhua.png',
            enable:true,
            fullskin:true,
            //fullimage:true,
			type:'trick',
            filterTarget(card,player,target){
                return player.canCompare(target)&&target.hp>player.hp;
            },
            async content(event,trigger,player){
                var num=0;
                game.countPlayer((current)=>{
                    var history=current.getHistory('useCard',(evt)=>{
                        return evt.card.name=='djcjiguchuanhua';
                    }).length
                    if(history)num+=history;
                });
                if(num>=2){
                    const{result:{bool}}=await player.chooseToCompare(event.targets[0]);
                    var loser=bool?event.targets[0]:player;
                    var winer=bool?player:event.targets[0];
                }else{
                    const{result:{bool}}=await player.chooseToCompare(event.targets[0]).set('small',true);
                    var loser=bool?event.targets[0]:player;
                    var winer=bool?player:event.targets[0];
                };
                if(game.hasPlayer(target=>{loser.canUse('djcjiguchuanhua',target,true,true)})){
                    const {result}=await loser.chooseControl('选项一','选项二').set('choiceList',['视为使用一张【击鼓传花】','受到'+num+'点伤害']).set('ai',()=>{
                        if(game.hasPlayer((current)=>{
                            return get.attitude(loser,current)<=2&&loser.canCompare(current)&&current!=winer&&current.hp>loser.hp
                        }))return '选项一';
                        if(_status.event.num>2)return '选项一';
                        return '选项二';
                    }).set('num',num);
                    if(result.control&&result.control!='cancel2'){
                        if(result.control=='选项一'){
                            const{result}=await loser.chooseUseTarget('djcjiguchuanhua',true);
                        }else{
                            await loser.damage(num,winer);
                        };
                    };
                }else{
                    await loser.damage(num,winer);
                };
            },
            ai:{
                order:10,
			    value:[3,1],
				useful:0.6,
                result:{
                    target(player,target){
                        return -3;
                    },
                },
            },
        },
        'djcdaqianlu':{//大千录 出牌阶段，你可以：1.弃置一张“苍”并视为受到1点伤害。2.弃置任意张“苍”，等量枚“蜣”，并对一名其他角色造成等量伤害。
            audio:true,
            image:'ext:点绛唇/card/image/djcdaqianlu.png',
            enable:true,
            fullskin:true,
            derivation:'djc_huan_lihuowang',
            type:'equip',
            subtype:'equip5',
            modTarget:true,
            toself:true,
            destroy:true,
            skills:['djcdaqianlu_skill'],
            ai:{
                basic:{
                    equipValue:3,
                    order:(card,player)=>{
                        const equipValue=get.equipValue(card,player)/20;
                        return player&&player.hasSkillTag('reverseEquip')?8.5-equipValue:8+equipValue;
                    },
                    useful:2,
                    value:(card,player,index,method)=>{
                        if(!player.getCards('e').includes(card)&&!player.canEquip(card,true))return 0.01;
                        const info=get.info(card),
                            current=player.getEquip(info.subtype),
                            value=current&&card!=current&&get.value(current,player);
                            let equipValue=info.ai.equipValue||info.ai.basic.equipValue;
                        if(typeof equipValue=='function'){
                            if(method=='raw')return equipValue(card,player);
                            if(method=='raw2')return equipValue(card,player)-value;
                            return Math.max(0.1,equipValue(card,player)-value);
                        }
                        if(typeof equipValue!='number')equipValue=0;
                        if(method=='raw')return equipValue;
                        if(method=='raw2')return equipValue-value;
                        return Math.max(0.1,equipValue-value);
                    },
                },
                result:{
                    target:(player,target,card)=>get.equipResult(player,target,card),
                },
            },
        },
        'djchuanfu':{
            audio:true,
            fullskin:true,
            type:'basic',
            derivation:'fhq_yuji',
            cardcolor:'none',
            enable:false,
            ai:{
                basic:{
                    useful:0,
                    value:0,
                },
            },
        },
    },
    translate:{
        'djcjiguchuanhua':'击鼓传花',
        'djcjiguchuanhua_info':'出牌阶段，你可以与一名体力值大于你的其他角色拼点。输的角色须选择一项:1.视为使用一张【击鼓传花】；2.受到X点伤害（X为本回合所有角色使用【击鼓传花】的次数）。',
        'djcdaqianlu':'大千录',
        'djcdaqianlu_info':'出牌阶段，你可以：1.弃置一张“苍”并视为受到1点伤害。2.弃置任意张“苍”，等量枚“蜣”，并对一名其他角色造成等量伤害。',
        'djchuanfu':'幻符',
        'djchuanfu_info':'基本牌，无花色，无效果。',
    },
    list:[
        ['heart',13,'djcjiguchuanhua'],
        ['club',13,'djcjiguchuanhua'],
        ['diamond',13,'djcjiguchuanhua'],
        ['spade',13,'djcjiguchuanhua'],
    ],
}